package com.heng.test.CG;

import net.sf.cglib.proxy.Enhancer;

public class CglibDynamicProxyDemo {

    public static void main(String[] args) {
        Enhancer enhancer = new Enhancer();
        enhancer.setSuperclass(KafkaService.class); // 设置目标类作为基类
        
        // 注册自定义拦截器
        enhancer.setCallback(new KafkaServiceInterceptor());

        // 创建代理实例
        KafkaService kafkaServiceProxy = (KafkaService) enhancer.create();

        // 测试调用
        String response = kafkaServiceProxy.produce("Test Message");
        System.out.println("Response from Proxy: " + response);
    }
}